/**
package com.caxxb.filter;

import com.alibaba.fastjson.JSON;
import com.caxxb.common.BaseContext;
import com.caxxb.common.R;


import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebFilter(filterName = "loginCheckFilter ",urlPatterns = "/*")
public class LoginCheckFilter implements Filter {

//    public static final AntPathMatcher PATH_MATCHER=new AntPathMatcher();


    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        HttpServletRequest request=(HttpServletRequest) servletRequest;
        HttpServletResponse response=(HttpServletResponse) servletResponse;

        String requestURI = request.getRequestURI();

        System.out.println("requestURI"+requestURI);

        String[] urls=new String[]{
                "/dreamproject/user/login",
                "/dreamproject/"
        };

        boolean check = check(urls, requestURI);

        System.out.println("check:"+check);

        if(check){

            filterChain.doFilter(request,response);
            return;
        }


        if(request.getSession().getAttribute("user")!=null ){
            System.out.println("用户已经登录");

            int userId = (int) request.getSession().getAttribute("user");

            BaseContext.setCurrentId(userId);
            filterChain.doFilter(request,response);
            return;
        }
            request.getRequestDispatcher("login.html").forward(request,response);
//        response.sendRedirect("login.html");
        return;
    }
    public boolean check(String[] urls,String requestURI){
        for (String url : urls) {

            boolean match=false;


            System.out.println("url:"+url);
            System.out.println("requestURI:"+requestURI);
            System.out.println("匹配结果"+url.equals(requestURI));

            if(url.equals(requestURI)){
                match=true;
            }

//            boolean match = PATH_MATCHER.match(url, requestURI);

            if(match){
                System.out.println("match:"+match);
                return true;
            }
        }
        return false;
    }

    @Override
    public void destroy() {

    }
}
**/